package com.fr.chicken.manager.share;

import com.fr.chicken.dao.SharLogDao;
import com.fr.chicken.model.SharLog;
import com.fr.chicken.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * 分享
 * @author bear
 * */
@Repository
public class ShareManager {
    @Autowired
    private SharLogDao sharLogDao;
    /**
     * 是否为今日第一次分享
     * */
    public boolean isTodayFistShare(long playerId){
        return sharLogDao.selectByPlayerIdAndTime(playerId, DateUtil.getCurrentTime()) <= 0;
    }

    /**
     * 是否为第一次分享
     * */
    public boolean isFirstShare(long playerId){
        return sharLogDao.selectByPlayerIdAndTime(playerId,null) <= 0;
    }

    /**
     * 增加一次分享记录
     * */
    public boolean share(long playerId){
        SharLog sl = new SharLog();
        sl.setPlayerId(playerId);
        sl.setSharTime(new Date());
        sl.setSharType(1);
        return sharLogDao.insert(sl) > 0;
    }
}
